package com.itheima.file;

import java.io.File;
import java.io.IOException;

public class Demo3File {
    public static void main(String[] args) throws IOException {
        File file1 = new File("day12_file&io\\abc");
        boolean exists1 = file1.exists();
        if(!exists1){
            file1.mkdirs();
        }
        File file2 = new File("day12_file&io\\abc\\hello.txt");
        file2.createNewFile();

        boolean directory = file1.isDirectory();
        System.out.println("directory = " + directory);

        boolean file = file2.isFile();
        System.out.println("file = " + file);

        boolean delete = file2.delete();
        System.out.println("delete = " + delete);

        boolean delete1 = file1.delete();
        System.out.println("delete1 = " + delete1);

        File file4 = new File("E:\\itcast");
        File[] files = file4.listFiles();
        for (File f : files) {
            System.out.println(f);
        }
        String name = file4.getName();
        System.out.println("name = " + name);

        String absolutePath = file4.getAbsolutePath();
        System.out.println("absolutePath = " + absolutePath);

        String path = file4.getPath();
        System.out.println("path = " + path);

        File f = new File("E:\\itcast");
        File[] listFiles = f.listFiles();
        for (File fl : listFiles) {
            if(fl.isFile()){
                fl.delete();
            }
        }
        f.delete();
    }
}
